package ar.com.angrymachine.hunter.ui;


import java.awt.Graphics;
import java.awt.Rectangle;

import ar.com.angrymachine.hunter.Game;
import ar.com.angrymachine.hunter.GraphicStyles;
import ar.com.angrymachine.hunter.HunterApp;
import ar.com.angrymachine.hunter.Locale;
import ar.com.angrymachine.gameui.ButtonWidget;
import ar.com.angrymachine.gameui.Widget;
import ar.com.angrymachine.gameui.ButtonWidget.ButtonListener;

public class StatusBarWidget extends Widget implements ButtonListener
{
	private ButtonWidget newGameButton;
	private ButtonWidget cheatButton;
    public StatusBarWidget(Widget parent, Rectangle area)
    {
        super(parent, area);
        cheatButton = new ButtonWidget(this, new Rectangle(getWidth()-80,getHeight()-30,70,20), Locale.CHEAT, this);
        newGameButton = new ButtonWidget(this, new Rectangle(getWidth()-80,getHeight()-60,70,20), Locale.NEW_GAME, this);
    }
    
    public void paint(Graphics g)
    {
        Game game = Game.current;
        if (game != null)
        {
            Rectangle statusBarArea = new Rectangle(0, 0, getWidth(),getHeight());
            GraphicStyles.paintStatusBar(g, statusBarArea);
        }
    }

	public void onPress(ButtonWidget widget)
	{
		if(widget == cheatButton)
		{
			if(Game.current != null)
			{
				Game.current.player.levelUp();
				//TODO:remove this hack
				Game.current.player.receiveAttack(100000);
			}
		}
		else
		if(widget == newGameButton)
		{
			HunterApp.app.resetGame();
		}
	}    
}
